<template>
	<view>你好你好aa</view>
</template>

<script>
	// import {GYZJMODEL as gyzjModel}from './utils/gyzjModel.js'
	export default {
	    onLoad:function(){
			console.log('我的天');
			/*这里打印了2.3.6*/
			console.log('plus.runtime.uniVersiona',plus.runtime.uniVersion);
			console.log('plus.os.name',plus.os.name);
			console.log('plus.runtime.appid',plus.runtime.appid);
			console.log('plus.device.uuid',plus.device.uuid);
			console.log('plus.runtime.uniVersiona',plus.runtime.uniVersion);
			console.log('plus.runtime.uniVersiona',plus.runtime.uniVersion);
			console.log('plus.runtime.uniVersiona',plus.runtime.uniVersion);
			/*仅支持竖屏*/
	       plus.screen.lockOrientation('portrait-primary');
		   //检测升级
		   uni.request({
		   	url:_self.gConfig.baseUrl+'update',
			method:'POST',
			data:{
				version:_self.$currentVersion,
				uniVersion:plus.runtime.uniVersion,//uni-app的基座版本号
				os:plus.os.name,
				appid:plus.runtime.appid,
				uuid:plus.device.uuid
			},
			success:(result)=>{
				console.log('请求成功的result',result);
				var data=result.data;
				console.log('请求成功的data的值',data);
				if(data.update&&data.wgtUrl){
					
					uni.downloadFile({
						url:data.wgtUrl,
						success:(downloadResult)=>{
							console.log('请求成功的downloadResult的值',downloadResult);
							if(downloadResult.statusCode===200){
								plus.runtime.install(downloadResult.tempFilePath,{force:true},function(){
									plus.nativeUI.toast('更新成功');
									plus.runtime.restart();
								},function(e){
									plus.nativeUI.toast('更新失败');
								})
							}
						}
					})
				}
				if(data.update&&data.pkgUrl){
					uni.showModal({
						title:'更新提示',
						showCancel:!data.force,
						content:data.note?data.note:'是否选择更新',
						success:(showResult)=>{
							if(showResult.confirm){
								plus.runtime.openURL(data.pkgUrl);
							}
						}
					})
				}
			}
		   })
		}
	}
</script>

<style>
</style>
